﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Orders.aspx.cs" Inherits="GPSTrackingWebsiteManager.Manager.Pages.Orders" %>

<!DOCTYPE html>

<link href="../../Css/GPSTrackingWebsite.css" rel="stylesheet" />
<link href="../../Css/messi.css" rel="stylesheet" />
<script src="../../Javascript/jquery-1.11.1.min.js"></script>
<script src="../../Javascript/messi.js"></script>
<script src="../../Javascript/Custom.js"></script>
<script src="../../Javascript/WindowMessageManager.js"></script>

<html xmlns="http://www.w3.org/1999/xhtml">

<telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
    <script type="text/javascript">
        function resizeGrid() {

            var height = (window.innerHeight) - 105;
            var tableView = $find("<%=OrdersGrid.ClientID %>");
            tableView.get_element().style.height = (height) / 2 + "px";

            var tableView2 = $find("<%=OrderDetailsGrid.ClientID %>");
            tableView2.get_element().style.height = (height - (height) / 2) + "px";

            document.getElementById('HiddenFieldHeight').value = (height);
        }

        //Windows Message Manager 
        var objWindowsMessageManager = new WindowsMessageManager();
    </script>
</telerik:RadScriptBlock>

<head runat="server">
</head>
<body onresize="resizeGrid()" style="overflow: hidden">
    <form id="form1" runat="server">
    <div>
      <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>        
        <asp:HiddenField ID="HiddenFieldHeight" runat="server" Value="323" />
        <asp:HiddenField ID="HiddenFieldError" runat="server" Value="" />
        
                            <telerik:RadTabStrip ID="rtsStocks" runat="server" SelectedIndex="0" MultiPageID="rmpStocks" ></telerik:RadTabStrip>
                    <telerik:RadMultiPage ID="rmpStocks" runat="server" SelectedIndex="0">
                    <telerik:RadPageView ID="rpvStocks" runat="server">        
        
        <table style="width: 100%; text-align: left">
					<tr>
                        <td>
                            <fieldset>
                                <legend>Seleccione las fechas a Consultar</legend>
                                <telerik:RadDatePicker ID="beginDateSelected" runat="server" DateInput-Label="Fecha Desde" style="text-align: left" Height="24px" Width="200px" Calendar-CultureInfo="es-CR">
							        <Calendar UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>
			                        <DateInput DateFormat="dd/MM/yyyy" DisplayDateFormat="dd/MM/yyyy"  Height="24px" LabelWidth="50%"></DateInput>
		                        </telerik:RadDatePicker>

                                <telerik:RadDatePicker ID="endDateSelected" runat="server" DateInput-Label="Fecha Hasta" style="text-align: left" Height="24px" Width="200px" Calendar-CultureInfo="es-CR">
							        <Calendar UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>
			                        <DateInput DateFormat="dd/MM/yyyy" DisplayDateFormat="dd/MM/yyyy" Height="24px" LabelWidth="50%"></DateInput>
		                        </telerik:RadDatePicker>
                                &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                                <telerik:RadButton ID="btnOrderSearch" runat="server" Text="Buscador" Height="32px" Width="32px" AutoPostBack="true" ToolTip="Consultar Datos" OnClick="btnOrderSearch_Click">
                                    <Image ImageUrl="../../Template/Icons/32px/Actions-document-find-icon.png" />
                                </telerik:RadButton>
                                 &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                                <telerik:RadButton ID="btnOrderUpdateStatusPro" runat="server" Text="Actualizar estado en Proceso" Height="32px" Width="32px" AutoPostBack="true" ToolTip="Actualizar estado en Proceso" OnClick="btnOrderUpdateStatusPro_Click">
                                    <Image ImageUrl="../../Template/Icons/32px/running_process.png" />
                                </telerik:RadButton>
                                 &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                                <telerik:RadButton ID="btnOrderUpdateStatusFin" runat="server" Text="Actualizar estado en Finalizado" Height="32px" Width="32px" AutoPostBack="true" ToolTip="Actualizar estado en Finalizado" OnClick="btnOrderUpdateStatusFin_Click">
                                    <Image ImageUrl="../../Template/Icons/32px/Refresh_key.png" />
                                </telerik:RadButton>
                            </fieldset>                      
                        </td>
                    </tr>

                    </table>


                   
								<telerik:RadGrid ID="OrdersGrid" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Height="100%" AllowMultiRowSelection="true" OnNeedDataSource="OrdersGrid_NeedDataSource" AllowSorting="true" GroupingSettings-CaseSensitive="false" OnSelectedIndexChanged="OrdersGrid_SelectedIndexChanged" OnItemCommand="OrdersGrid_ItemCommand">
		                            <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                                    <CommandItemTemplate>
                                        <div style="padding: 5px 5px;"> Ordenes: 
                                                <asp:LinkButton ID="lbClearFilters" runat="server" OnClick="lbClearFilters_Click"  Visible='<%# !OrdersGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>                                                                               
				                                <asp:LinkButton ID="lbShowError" runat="server" OnClick="lbShowError_Click" Visible='<%# HiddenFieldError.Value == string.Empty ? false : true %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/bug-icon.png"/>Error Técnico</asp:LinkButton>                                                                                                               
                                        </div>                        
                                    </CommandItemTemplate>

                                        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                            <HeaderStyle Width="20px"></HeaderStyle>
                                        </RowIndicatorColumn>

                                        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                            <HeaderStyle Width="20px"></HeaderStyle>
                                        </ExpandCollapseColumn>

                                        <Columns>
                                            <telerik:GridBoundColumn DataField="CompanyId" HeaderText="Compañía" UniqueName="CompanyId" ForceExtractValue="Always"  Display="false">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="OrderId" HeaderText="ID Orden" UniqueName="OrderId" ForceExtractValue="Always"  HeaderStyle-Width="100px" FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="ClientId" HeaderText="ID Cliente" UniqueName="ClientId" ForceExtractValue="Always"  Display="false">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="ClientName" HeaderText="Nombre Cliente" UniqueName="ClientName" ForceExtractValue="Always" HeaderStyle-Width="100px" FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" ItemStyle-HorizontalAlign="Center" >
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Username" HeaderText="Usuario" UniqueName="Username" ForceExtractValue="Always" HeaderStyle-Width="100px" FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Name" HeaderText="Nombre Usuario" UniqueName="Name" HeaderStyle-Width="100px" FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" >
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="FirstName" HeaderText="Apllido" UniqueName="FirstName" HeaderStyle-Width="100px" FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" >
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Status" HeaderText="Estatus" UniqueName="Status" HeaderStyle-Width="100px" FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" AutoPostBackOnFilter="true" >
                                            </telerik:GridBoundColumn>
                                        </Columns>

                                        <EditFormSettings>
                                            <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                        </EditFormSettings>

                                        <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                                    </MasterTableView>
                                      <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                                            <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True">
                                            </Scrolling>  <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
                                      </ClientSettings>
                                    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>

                                    <FilterMenu EnableImageSprites="False"></FilterMenu>
                                </telerik:RadGrid> 
					            <br/>
                                <telerik:RadGrid ID="OrderDetailsGrid" runat="server" AllowSorting="true" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Height="100%" Width="100%" GroupingSettings-CaseSensitive="false" OnNeedDataSource="OrderDetailsGrid_NeedDataSource">
                                   <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                                    <CommandItemTemplate>
                                        <div style="padding: 5px 5px;"> Detalle Orden: 
                                             <asp:LinkButton ID="lbClearStockFilters" runat="server" OnClick="lbClearStockFilters_Click"  Visible='<%# !OrderDetailsGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>                                                                               
                                             <asp:LinkButton ID="lbShowError" runat="server" OnClick="lbShowError_Click" Visible='<%# HiddenFieldError.Value == string.Empty ? false : true %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/bug-icon.png"/>Error técnivo</asp:LinkButton>   
                                        </div>                        
                                    </CommandItemTemplate>
                                        <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Nuevo Master" RefreshText="Actualizar"></CommandItemSettings>

                                        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                            <HeaderStyle Width="20px"></HeaderStyle>
                                        </RowIndicatorColumn>

                                        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                            <HeaderStyle Width="20px"></HeaderStyle>
                                        </ExpandCollapseColumn>

                                        <Columns>
                                            <telerik:GridBoundColumn DataField="CompanyId" HeaderText="Compañía" UniqueName="CompanyId"  ForceExtractValue="Always" Display="false" ReadOnly="true">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="OrderId" HeaderText="ID Orden" UniqueName="OrderId"  ForceExtractValue="Always" Display="false" ReadOnly="true">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="StockId" HeaderText="ID Producto" UniqueName="StockId"  ForceExtractValue="Always" ReadOnly="true" FilterControlWidth="50px" CurrentFilterFunction="Contains" ShowFilterIcon="false"  HeaderStyle-Width="70px" AutoPostBackOnFilter="true" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Name" HeaderText="Nombre" UniqueName="Name"
                                                 FilterControlWidth="100px" CurrentFilterFunction="Contains" ShowFilterIcon="false"  HeaderStyle-Width="130px" AutoPostBackOnFilter="true">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridNumericColumn DataField="Quantity" DecimalDigits="0" FilterControlAltText="Filter Quantity column" HeaderText="Cantidad" UniqueName="Quantity" AllowFiltering="true" FilterControlWidth="100px" CurrentFilterFunction="Contains" ShowFilterIcon="false"  HeaderStyle-Width="130px" AutoPostBackOnFilter="true" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                                            </telerik:GridNumericColumn>
                                            <telerik:GridNumericColumn DataField="Price" DecimalDigits="0"  HeaderText="Precio" UniqueName="Price" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right"
                                                 FilterControlWidth="100px" CurrentFilterFunction="Contains" ShowFilterIcon="false"  HeaderStyle-Width="130px" AutoPostBackOnFilter="true">
                                            </telerik:GridNumericColumn>
                                            <telerik:GridNumericColumn DataField="Total" DecimalDigits="0"  HeaderText="Total" UniqueName="Total" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right"
                                                 FilterControlWidth="100px" CurrentFilterFunction="Contains" ShowFilterIcon="false"  HeaderStyle-Width="130px" AutoPostBackOnFilter="true">
                                            </telerik:GridNumericColumn>
                                        </Columns>

                                        <EditFormSettings>
                                            <EditColumn InsertText="Agregar" UpdateText="Actualizar" CancelText="Cancelar" ButtonType="ImageButton"></EditColumn>
                                        </EditFormSettings>
                                    </MasterTableView>
                                       <ClientSettings EnableRowHoverStyle="true">
                                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"></Scrolling>
                                     <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
                                </ClientSettings>
                                <FilterMenu EnableImageSprites="False"></FilterMenu>
                                </telerik:RadGrid>

                        </telerik:RadPageView>
                        </telerik:RadMultiPage>


    </div>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"></telerik:RadAjaxLoadingPanel>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>

        <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnOrderUpdateStatusPro">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rmpStocks" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError" /> 
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnOrderUpdateStatusFin">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rmpStocks" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass=""  />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError" /> 
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnOrderSearch">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rmpStocks" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError" /> 
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="OrdersGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rmpStocks" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError" /> 
                    </UpdatedControls>
                </telerik:AjaxSetting>

                <telerik:AjaxSetting AjaxControlID="OrderDetailsGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="OrderDetailsGrid" LoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError" /> 
                    </UpdatedControls>
                </telerik:AjaxSetting>

            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>

    </form>
</body>
</html>
